<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="tutorial.css">
<TITLE>
Matching
</TITLE>
</HEAD>
<BODY >
<A HREF="tutorial028.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial030.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc63">4.6</A>&nbsp;&nbsp;Matching</H2>
In ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> you can write clauses that use <B>matching</B> (or one-way
unification) instead of head unification. 
Such clauses are written with the <B>?-</B> functor instead of <B>:-</B>.
Matching has the property that no variables in the caller will be bound.
For example

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
p(f(a,X)) ?- writeln(X).
</PRE></BLOCKQUOTE></TD>
</TR></TABLE>
will fail for the following calls:
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
?- p(F).
?- p(f(A,B)).
?- p(f(A,b)).
</PRE></BLOCKQUOTE>
and succeed (printing b) for
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
?- p(f(a,b)).
</PRE></BLOCKQUOTE>
Moreover, the clause

	<TABLE CELLPADDING=10>
<TR><TD BGCOLOR="#CCCCFF">
	<BLOCKQUOTE CLASS="quote"><PRE>
q(X,X) ?- true.
</PRE></BLOCKQUOTE></TD>
</TR></TABLE>
will fail for the calls
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
?- q(a,b).
?- q(a,B).
?- q(A,b).
?- q(A,B).
</PRE></BLOCKQUOTE>
and succeed for
<BLOCKQUOTE CLASS="quote"><PRE CLASS="verbatim">
?- q(a,a).
?- q(A,A).
</PRE></BLOCKQUOTE>
<HR>
<A HREF="tutorial028.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="tutorial023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="tutorial030.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
